/* 
 * File:   binary_tree.h
 * Author: aishwarya
 *
 * Created on March 19, 2011, 4:15 PM
 */

#ifndef BINARY_TREE_H
#define	BINARY_TREE_H

#ifdef	__cplusplus
extern "C" {
#endif

#include "avdtech.h"
#include "allocator.h"

    typedef struct _tree_node {
        struct _tree_node *left;
        struct _tree_node *right;
        struct _tree_node *parent;
        void *data;        
    } tree_node;

    typedef struct _bst {
        KEYCMP _keycmpfn;
        DATACPY _datacpyfn;
        DELNODE _delnodefn;
        PRINTNODE _printfn;

        tree_node *root;
        size_t e_size ;
    } BST;

    void bst_init(BST *t, size_t e_size, KEYCMP k, DATACPY d, DELNODE n, PRINTNODE p);
    void bst_clean(BST *t);
    int bst_search(BST *t, void *data);
    int bst_insert(BST *t, void *data);
    int bst_delete(BST *t, void *data);
    void bst_inorder(BST *t);

#ifdef	__cplusplus
}
#endif

#endif	/* BINARY_TREE_H */

